// packageA/pages/cashService/roleSelection/roleSelection.js

const { imgPath } = require('../../../utils/request')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgPath: imgPath,
  },
  goHomePage(e) {
    console.log(wx.getStorageSync('userInfo'))
    if (e.currentTarget.dataset.role == 'operator') {
      if (wx.getStorageSync('userInfo').loginType == 1) {
        wx.setStorageSync('checkStationFlag', true)
        wx.navigateTo({
          url: '/pages/cashService/operator/operator',
        })
      }else if (wx.getStorageSync('userInfo').loginType == 4 || wx.getStorageSync('userInfo').loginType == 5) { //三方操作员
        wx.navigateTo({
          url: '/pages/cashService/third/list/list',
        })
      } else {
        // 操作员登录页
        wx.navigateTo({
          url: '/pages/cashService/operator/login/login',
        })
      }
    } else if (e.currentTarget.dataset.role == 'admin') {
      if (wx.getStorageSync('userInfo').loginType == 2 || wx.getStorageSync('userInfo').loginType == 3) {
        wx.navigateTo({
          url: '/pages/cashService/admin/personManage/personManage',
        })
      }else if(wx.getStorageSync('userInfo').loginType == 5){ //清分公司管理员
        wx.redirectTo({
          url: '/pages/cashService/third/admin/personManage/personManage',
        })
      } else {
        // 管理员登录页
        wx.navigateTo({
          url: '/pages/cashService/admin/login/login?type=' + e.currentTarget.dataset.role,
        })
      }
    } else {
      // 会计登录页
      wx.navigateTo({
        url: '/pages/cashService/admin/login/login?type=' + e.currentTarget.dataset.role,
      })
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.setNavigationBarTitle({
      title: '上门收款智能服务'
    })
  },
  onShow: function (options) {

  }
})